
#include <BLayout>
#include <BSizePolicy>
#include "member_BScrollWidget.h"

using namespace BWE;

member_BScrollWidget::member_BScrollWidget(BScrollWidget* scrollWidget)
{
	boss = scrollWidget;
	orientation = Orientation_None;
}
member_BScrollWidget::~member_BScrollWidget()
{

}

void member_BScrollWidget::freshArea()
{
	if (!layout)
		return;
	BRect crect = boss->clientRect();
	BSize minSize = layout->minSize();
	BSize maxSize = layout->maxSize();
	BSize sizeHint = layout->sizeHint();
	BRect rect = layout->rect();

	int width = layout->rect().width();
	int height = layout->rect().height();
	if (orientation == Orientation_Vertical)
	{
		width = bMax(sizeHint.width(), crect.width());
		height = sizeHint.height();
	}
	if (orientation == Orientation_Horizontal)
	{
		width = sizeHint.width();
		height = bMax(sizeHint.height(), crect.height());
	}
	BRect area = boss->area();
	area.setSize(width, height);
	boss->setArea(area);
	boss->scrollArea();
}

void member_BScrollWidget::procContentChanged()
{
	boss->fresh();
}
